#pragma once

#include <memory>

namespace lfq
{

#define LOCKFREE_QUEUE_ENTRY_ALIGNMENT	8

	template <typename T> class __declspec(align(LOCKFREE_QUEUE_ENTRY_ALIGNMENT)) lockfree_queue_entry
	{
		static_assert(sizeof(T) > 0, "must have size");

	public:
		/// reserved for entry_allocator
		void * volatile m_allocator_hint;

		lockfree_queue_entry * volatile m_next;
		T m_value;

		explicit lockfree_queue_entry(const T & value) : m_value(value), m_next(nullptr) {}

		static lockfree_queue_entry * reverseList(lockfree_queue_entry * list)
		{
			lockfree_queue_entry * rst = nullptr;

			while (list != nullptr)
			{
				lockfree_queue_entry * oldList = rst;

				rst = list;
				list = list->m_next;

				rst->m_next = oldList;
			}

			return rst;
		}
	};


}
